﻿Imports System.Xml

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("about:blank")
    End Sub

    Private Sub MetaverseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MetaverseToolStripMenuItem.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            ExportData()
            Dim xmlFilePath As String = GetMVFilePath()
            Dim xmlDoc1 As New XmlDocument
            xmlDoc1.Load(xmlFilePath)
            WebBrowser1.DocumentText = Transform("ActiveMetaverseDesign.XSLT", xmlDoc1, "")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Get Metaverse Configuration")
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub WindowsAzureActiveDirectoryConnectorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles WindowsAzureActiveDirectoryConnectorToolStripMenuItem.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            WebBrowser1.DocumentText = GetMaStats("Windows Azure Active Directory Connector")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Get Management Agent Info Error")
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub ActiveDirectoryConnectorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ActiveDirectoryConnectorToolStripMenuItem.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            WebBrowser1.DocumentText = GetMaStats("Active Directory Connector")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Get Management Agent Info Error")
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub AttributeFlowToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AttributeFlowToolStripMenuItem.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            ExportData()

            Dim xmlDoc As New XmlDocument
            xmlDoc.LoadXml("<mv-population><mv-object-types/></mv-population>")
            Dim newNode As XmlElement = xmlDoc.CreateElement("ma-data")
            xmlDoc.DocumentElement.AppendChild(newNode)
            GetMaConfig(xmlDoc, newNode)
            GetImportFlows(xmlDoc)
            xmlDoc.Save("c:\temp\1.xml")
            GetExportFlows(xmlDoc)
            WebBrowser1.DocumentText = Transform("AttributeFlows.XSLT", xmlDoc, "")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Get Management Agent Info Error")
        Finally
            Me.Cursor = Cursors.Default
        End Try

    End Sub
End Class
